package com.quanta.edaily.bean;

import com.quanta.edaily.bean.contants.ResultCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonResponse {
    private int code;
    private String msg;
    private Object data;

    public static JsonResponse success(String msg) {
        return success(msg, null);
    }

    public static JsonResponse success(String msg, Object object) {
        JsonResponse jsonResponse = new JsonResponse();
        jsonResponse.setCode(ResultCode.SUCCESS);
        jsonResponse.setMsg(msg);
        jsonResponse.setData(object);
        return jsonResponse;
    }

    public static JsonResponse error(int code,String msg) {
        JsonResponse jsonResponse = new JsonResponse();
        jsonResponse.setCode(code);
        jsonResponse.setMsg(msg);
        return jsonResponse;
    }

    public static JsonResponse paramError(String msg) {
        return error(ResultCode.PARAM_ERROR, msg);
    }

    public static JsonResponse systemError(String msg) {
        return error(ResultCode.SYSTEM_ERROR, msg);
    }
}
